//
//  RefreshedTableView.m
//  All-Know
//
//  Created by enghou on 16/3/8.
//  Copyright © 2016年 heyuebin@all-know.com. All rights reserved.
//

#import "RefreshedTableView.h"
@interface RefreshedTableView()<SRRefreshDelegate,UIScrollViewDelegate>
@end
@implementation RefreshedTableView
{
    SRRefreshView *_smileView;
    UIActivityIndicatorView *activeIndicator;
}

-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder:aDecoder];
    if (self) {
        _smileView=[[SRRefreshView alloc]init];
        _smileView.delegate=self;
        _smileView.upInset= 0;
        _smileView.slimeMissWhenGoingBack=YES;
        _smileView.slime.bodyColor = [UIColor blackColor];
        _smileView.slime.skinColor = [UIColor whiteColor];
        _smileView.slime.lineWith = 1;
        _smileView.slime.shadowBlur = 4;
        _smileView.slime.shadowColor = [UIColor blackColor];
        [self addSubview:_smileView];
        UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
        activeIndicator=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
        activeIndicator.center=view.center;
        activeIndicator.color=[UIColor lightGrayColor];
        [activeIndicator stopAnimating];
        [view addSubview:activeIndicator];
        self.tableFooterView=view;
    }
    return self;
}

-(id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{
    self=[super initWithFrame:frame style:style];
    if(self)
    {
        _smileView=[[SRRefreshView alloc]init];
        _smileView.delegate=self;
        _smileView.upInset=0;
        _smileView.slimeMissWhenGoingBack=YES;
        _smileView.slime.bodyColor = [UIColor blackColor];
        _smileView.slime.skinColor = [UIColor whiteColor];
        _smileView.slime.lineWith = 1;
        _smileView.slime.shadowBlur = 4;
//        _smileView.slime
        _smileView.slime.shadowColor = [UIColor blackColor];
        [self addSubview:_smileView];
        UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
        activeIndicator=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
        activeIndicator.center=view.center;
        activeIndicator.color=[UIColor lightGrayColor];
        [activeIndicator stopAnimating];
        [view addSubview:activeIndicator];
        self.tableFooterView=view;
    }
    return self;
}

-(void)addFooter{
    
}

-(void)endAnimation{
    [self setStartAnimation:NO];
    [self.smileView endRefresh];
}

-(void)setStartAnimation:(BOOL)startAnimation
{
    _startAnimation=startAnimation;
    if(startAnimation)
    {
        [activeIndicator startAnimating];
    }else
    {
        [activeIndicator stopAnimating];
    }
}
-(void)slimeRefreshStartRefresh:(SRRefreshView *)refreshView
{
    [self.refreshDelegate beginRefresh];
}
@end
